(function(){
    //用户中心菜单
    var setInterval001=""; var _usernameWidth='';
    function userSelectShow(){
        clearInterval(setInterval001);
        var _username=$("#selectNavUserName");
        _usernameWidth=_usernameWidth?_usernameWidth:_username.width();
        _username.css({width:_usernameWidth+1});
        _username.find("div").css({width:_username.width()-24});
       //_username.css({width:_username.width()});
        _username.addClass("on");
        var _oTop=_username.offset().top;
        var	_oHeight=_username.outerHeight();
        $("#userMenu_option").css({"right": 0,"top":_oTop+_oHeight+1});
        $("#userMenu_option").show();
    }

    function userSelectHide(){
        clearInterval(setInterval001);
        var _username=$("#selectNavUserName");
        setInterval001=setInterval(function(){
            _username.removeClass("on");
            $("#userMenu_option").hide();
        },50);
    }

    function companyNav(){
        var hnav_html='<ul>' +
            '<li class="mobile"><i></i><a href="'+mainUrl('mobile_help')+'">手机版</a></li>' +
            '<li class="refresh"><a href="'+mainUrl('/company/welcome?refreshtip=yes')+'">刷新职位</a><i></i></li>' +
            '<li id="selectNavUserName" class="userName">' +
            '<div><a href="'+mainUrl('/')+'"><span>'+company_logininfo_name+'</span><i></i></a></div>' +
            '</li></ul>';
        var hnav_option_html='<div id="userMenu_option" class="userMenu"><ul>' +
            '<li><a href="'+mainUrl('/company/welcome')+'"><span>账户中心</span></a></li>' +
            '<li class="resume"><a href="'+mainUrl('/company/jobadmin')+'"><i></i><span>职位管理</span><b>管理</b></a></li>' +
            '<li class="notice"><a href="'+mainUrl('/company/resume_message')+'"><i></i><span>收到简历</span><b>查看</b></a></li>' +
            '<li><a href="'+mainUrl('/company/resume_favorite')+'"><span>人才库</span><b>查看</b></a></li>' +
            '<li class="favorites"><a href="'+mainUrl('/company/interview_manage')+'"><i></i><span>面试管理</span><b>相看</b></a></li>' +
            '<li class="set"><a href="'+mainUrl('/company/set_account')+'"><i></i><span>账号设置</span><b>设置</b></a></li>' +
            '<li><a href="'+mainUrl('/company/logout')+'"><span>安全退出</span></a></li>' +
            '</ul></div>';

        $("#usernavcon").html(hnav_html);
        $(".head .wrapper .logAndReg").append(hnav_option_html);
        $("#selectNavUserName").hover(
            function () {
                userSelectShow();
            },
            function () {
                userSelectHide();
            }
        );
        $("#userMenu_option").hover(
            function () {
                userSelectShow();
            },
            function () {
                userSelectHide();
            }
        );
    }

    function personalNav(){
        var hnav_html='<li class="mobile"><i></i><a href="'+mainUrl('mobile_help')+'">手机版</a></li>' +
            '<li class="refresh"><a href="'+mainUrl('/personal/resume_refresh')+'">刷新简历</a><i></i></li>' +
            '<li id="selectNavUserName" class="userName">' +
            '<div><a href="'+mainUrl('/')+'"><span>'+personal_logininfo_name+'</span><i></i></a></div>' +
            '</li>';
        var hnav_option_html='<div id="userMenu_option" class="userMenu"><ul>' +
            '<li><a href="'+mainUrl('/personal/welcome')+'"><span>账户中心</span></a></li>' +
            '<li class="resume"><a href="'+mainUrl('/personal/resume_mange')+'"><i></i><span>我的简历</span><b>完善</b></a></li>' +
            '<li class="notice"><a href="'+mainUrl('/personal/resume_mange')+'"><i></i><span>面试通知</span><b>查看</b></a></li>' +
            '<li><a href="'+mainUrl('/personal/resume_send')+'"><span>申请的职位</span><b>查看</b></a></li>' +
            '<li class="favorites"><a href="'+mainUrl('/personal/favorites')+'"><i></i><span>职位收藏夹</span><b>相看</b></a></li>' +
            '<li class="set"><a href="'+mainUrl('/personal/set_account')+'"><i></i><span>账号设置</span><b>设置</b></a></li>' +
            '<li><a  href="'+mainUrl('/personal/logout')+'"><span>安全退出</span></a></li>' +
            '</ul></div>';

        $("#usernavcon").html(hnav_html);
        $(".head .wrapper .logAndReg").append(hnav_option_html);
        $("#selectNavUserName").hover(
            function () {
                userSelectShow();
            },
            function () {
                userSelectHide();
            }
        );
        $("#userMenu_option").hover(
            function () {
                userSelectShow();
            },
            function () {
                userSelectHide();
            }
        );
    }

    function globalNav(){
        var hnav_html='<li class="mobile"><i></i><a href="'+mainUrl('mobile_help')+'">手机版</a></li>' +
            '<li><a href="'+mainUrl('/personal/welcome')+'">个人登录</a></li>' +
            '<li><a href="'+mainUrl('/company/welcome')+'"><span>企业登录</span></a></li>' +
            '<li><a href="javascript:void(0)">经纪人登录</a></li>' +
            '<li><a href="javascript:void(0)">学校登录</a></li>' +
            '<li><a href="javascript:void(0)">终端入口</a></li>' +
            '<li id="regNav" class="reg"><a href="javascript:void(0)">注册</a><i></i></li>';
        // '<li><a href="'+mainUrl('/personal/register')+'">个人注册</a></li>' +
        $("#usernavcon").html(hnav_html);
        var hnav_option_html='<div id="regNav_option" class="regNavMenu"><ul>' +
            '<li><a href="'+mainUrl('/personal/register')+'"><span>个人注册</span></a></li></li>' +
            '<li><a  href="'+mainUrl('/company/register')+'"><span>企业注册</span></a></li>' +
            '</ul></div>';
        $(".head .wrapper .logAndReg").append(hnav_option_html);
        //通用
        var setIntervalRegNav="";
        function regNavShow(){
            clearInterval(setIntervalRegNav);
            var _nav=$("#regNav");
            _nav.addClass("on");
            $("#regNav_option").show();
        }
        function regNavHide(){
            clearInterval(setIntervalRegNav);
            var _nav=$("#regNav");
            setIntervalRegNav=setInterval(function(){
                _nav.removeClass("on");
                $("#regNav_option").hide();
            },50);
        }
        $("#regNav").hover(
            function () {
                regNavShow();
            },
            function () {
                regNavHide();
            }
        );
        $("#regNav_option").hover(
            function () {
                regNavShow();
            },
            function () {
                regNavHide();
            }
        );
    }

    if(company_logininfo_name!=''){//企业登录
        companyNav();
    }else if(personal_logininfo_name!=''){//个人登录
        personalNav();
    }else{//没有登录
        globalNav();
    }


    //检查用户是不是登录
    if(personal_logininfo_name != '' && personal_logininfo_name != 'undefined'){
        //检查个人的cookie是不是存在
        if(getCookie('personal_cookie') == null || getCookie('personal_cookie') == ''){
        }
        setPersonalCookie();
    }

    /**
     * 设置个人登录刷新
     */
    function setPersonalCookie(){
        $.get("personal/set_personal_cookie", function(data){
            if(data.status == '1'){
                setCookie('personal_cookie', 1,  1 / 24);
                layer.open({
                    type: 1,
                    title: "温馨提示",
                    move: false,
                    skin: 'layui-layer-rim', //加上边框
                    area: ['480px', '300px'], //宽高
                    content: '<div class="refresh_resume" style="padding:0px; width:450px;"><div class="refresh">' +
                    '<div class="authentication">' +
                    '<span class="planIco">今天还没刷新简历，刷新提高简历曝光率!<br>刷新前请确认以下信息准确完整：</span>' +
                    '<span class="planTip">手机号码：' + data.info.mobile + '</span>' +
                    '<span class="planTip">求职状态：' + data.info.job_status + ' <a href="/personal/resume_refresh">修改</a></span>' +
                    '<span class="planTip">您的简历最近一次更新日期是：' + data.info.updatetime + '</span>' +
                    '<span class="planAgain"><a onclick="cookieRefresh()">刷新简历</a></span>' +
                    '<span class="planAgain planCancel"><a href="javascript:layer.closeAll()">以后再说</a></span>' +
                    '</div>' +
                    '</div></div>'
                });
            }else if(data.status == '2'){
                setCookie('personal_cookie', 1,  1 / 24);
            }
        });
    }
})(jQuery);

$(function(){
    //分站功能 判断是不是添加分站
    if($('#station').length > 0){
        $('.mainNav .select span').hover(function(){
            $('#station').show().hover(function(){
                $(this).show();
            },function(){
                $(this).hide();
            });
        },function(){
            $('#station').hide();
        });
    }
});